home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8592 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: butler.dmi.min.dk!news!lastec
  2. From: lastec@karen.dmi.min.dk (Lars Toeffner-Clausen)
  3. Newsgroups: gnu.g++,gnu.g++.help,comp.lang.c++
  4. Subject: Re: Overloaded new operator in C++
  5. Date: 19 Feb 1996 08:17:13 GMT
  6. Organization: Oersted Science Data Centre, Danish Meteorological Institute,
  7.     Denmark
  8. Message-ID: <LASTEC.96Feb19091713@karen.dmi.min.dk>
  9. References: <4g0boe$c37@maverick.tad.eds.com>
  10. NNTP-Posting-Host: karen.dmi.min.dk
  11. In-reply-to: venkat@nemesis.pln.rboc.eds.com's message of 15 Feb 1996 22:23:10
  12.     GMT
  13.  
  14. In article <4g0boe$c37@maverick.tad.eds.com> venkat@nemesis.pln.rboc.eds.com (User Jdsmith) writes:
  15.  
  16. > I am experiencing a problem with overloading the 
  17. > new operator when allocating an array of classes.
  18.  
  19. You need two functions - which can also be defined on a per-class basis:
  20.  
  21.     void *operator new(size_t size);
  22.     void *operator new[](size_t size);
  23.  
  24. > I assumed that the overloaded new operator would be called with the
  25. > number of bytes (the first parameter) being set to:
  26. > sizeof(class) * arrayCount
  27.  
  28. This is true - also for the new[] operator.
  29. -- 
  30. "We need a plan to diverge from", Fesser
  31. --
  32. .---------------------------------------------------------.
  33. | Lars Toeffner-Clausen         e-mail: lastec@dmi.min.dk |
  34. | Oersted Science Data Center   Phone: +45 3915 7497      |
  35. | Lyngbyvej 100                 Fax: +45 3915 7460        |
  36. | DK - 2100 Koebenhavn Oe                                 |
  37. `---------------------------------------------------------'
  38.